<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
     <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
      /*div form .contTable>tbody>tr.success>td:nth-last-child(1){background:rgb(255, 186, 140);}*/
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
        <h2 class="title_color text-center">经销商盈利分析</h2>
    </div>
    <!-- 标题 -->
    <div class="form-inline">
    <form action="" method="post" id="f1">
     <table class="row-margin-top tab-content table-bordered table text-left" border="1" style="margin-bottom: 1px">
          <tr>
              <td style="min-width: 120px" class="text-right"><label for="" class="form-label">财年：</label>
             </td>
             <td>
              <div class="input-group">
                <select name="cid" id="cid" class="select form-control">
                 {volist name="cainian" id="c"}
                  <option value="{$c.id}" {if $cid==$c.id} selected {/if}>{$c.title}</option>
                 {/volist}
          </select>
               </div>
            
             </td>
              <td style="min-width: 120px" class="text-right"><label for="" class="form-label">考核期：</label>
             </td>
             <td>
              <select name="kid" id="" class="select form-control">
                
                <option value="1" {if $kid==1}selected{/if}>一级考核期</option>
                <option value="2" {if $kid==2}selected{/if}>二级考核期</option>
              </select>
             </td>
              <td style="min-width: 120px" class="text-right"><label for="" class="form-label">分区：</label>
             </td>
             <td>
                <select name="fenqu" id="fenqu" class="select form-control">
                  <option value="0">请选择</option>
                  {volist name="zoning" id="c"}
                    <option value="{$c.id}" {if $c.id==$fenqu} selected{/if}>{$c.title}</option>
                  {/volist}
                </select>
             </td>
             </tr>
            <tr>
              <td style="min-width: 120px" class="text-right"><label for="" class="form-label">省份：</label>
             </td>
             <td>
                 <select name="provice" id="province" class="select form-control">
                  <option value="0">请选择</option>
                  {volist name="sheng" id="c"}
                    <option value="{$c.id}" {if $c.id==$provice} selected{/if}>{$c.title}</option>
                  {/volist}
                  
                </select>
             </td>
               <td style="min-width: 120px" class="text-right"><label for="" class="form-label">城市：</label>
             </td>
             <td>
               <select name="city" id="city" class="select form-control">
                <option value="0">请选择</option>
                {volist name="shi" id="c"}
                    <option value="{$c.id}" {if $c.id==$city} selected{/if}>{$c.title}</option>
                  {/volist}
            </select>
             </td>
               <td style="min-width: 120px" class="text-right"><label for="" class="form-label">经销商：</label>
             </td>
             <td>
              <select name="jxs" id="jxs" class="select form-control">
                <option value="0">请选择</option>
                {volist name="jingxiao" id="c"}
                    <option value="{$c.id}" {if $c.id==$jxs} selected{/if}>{$c.title}</option>
                  {/volist}
            </select>
             </td>
            </tr>
      </table>
  
       <table class="table table-bordered" style="margin:1px">
          <td  class="text-center">
          <button class="btn btn-info query" type="button">查询</button>
          <button class="btn btn-info emptyIf" type="button">清空查询条件</button>
          <button class="btn btn-info LendExcel" type="button" onclick="dc({$cid},{$kid},{$jxs})">导出EXcel</button>
        </td>
      </table>
    	<table class="table table-bordered" style="margin:1px">
			<tr>
				<td class="font-bold text-right">金额单位：元</td>
			</tr>
    	</table>
     {if $jxs}
      <table class="table row-margin-top table-bordered text-center bud_hei" id="Tinfo">
          <tr class="info">
            <th class="text-center">经销商编号</th>
            <th class="text-center">经销商名称</th>
            <th class="text-center">&nbsp;</th>
           {volist name="kaohe" id="kao"}
            <th class="text-center">{$kao.title}</th>
           {/volist}
           
            <th class="text-center">合计</th>
          </tr>
          <tbody>
          <tr>
             <td rowspan="8">{$agen.sn}</td>
             <td rowspan="8">{$agen.title}</td>
             <td>销售目标</td>
			       {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">{$kao.tar}</td>
             {/volist}
			       
			       <td class="ObjectNum text-right warning">{$agen.tar}</td>
          </tr>
             <tr class="success">
             <td>实际发运</td>
             {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">{$kao.fy}</td>
             {/volist}
             
             <td class="ObjectNum text-right warning">{$agen.fy}</td>
          </tr>
             <tr>
             <td>销售达成率</td>
              {volist name="kaohe" id="kao"}
              {if $kao.dc==0}
             <td class="ObjectNum text-right">-</td>
             {else}
                <td class="text-right"><span class="ObjectNum">{$kao.dc}</span>%</td>
             {/if}
             {/volist}
           
             {if $agen.dc==0}
             <td class="ObjectNum text-right warning">-</td>
             {else}
              <td class="text-right warning"><span class="ObjectNum">{$agen.dc}</span>%</td>
             {/if}
          </tr>
             <tr class="success">
             <td>成本</td>
              {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">-</td>
             {/volist}
            
             <td class="ObjectNum text-right warning">-</td>
          </tr>
             <tr>
             <td>费用预算</td>
              {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">{$kao.ys}</td>
             {/volist}
             
             <td class="ObjectNum text-right warning">{$agen.ys}</td>
          </tr>
             <tr class="success">
             <td>实际费用</td>
             {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">{$kao.sq}</td>
             {/volist}
            
             <td class="ObjectNum text-right warning">{$agen.sq}</td>
          </tr>
             <tr>
              <td>费用投放率</td>
              {volist name="kaohe" id="kao"}
             {if $kao.ff==0}
             <td class="ObjectNum text-right">-</td>
             {else}
                <td class="text-right"><span class="ObjectNum">{$kao.ff}</span>%</td>
             {/if}
             {/volist}
           
              {if $agen.ff==0}
             <td class="ObjectNum text-right warning">-</td>
             {else}
              <td class="text-right warning"><span class="ObjectNum">{$agen.ff}</span>%</td>
             {/if}
          </tr>
           <tr class="success">
            <td>利润</td>
             {volist name="kaohe" id="kao"}
             <td class="ObjectNum text-right">-</td>
             {/volist}
           
             <td class="ObjectNum text-right warning">-</td>
          </tr>
          </tbody>
      </table>
      {/if}
</form>
    </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- <script src="js/plugins/layer/laydate/laydate.js"></script> -->
     <script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="__STATIC__/layout/js/common.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
    function dc(cid,kid,jxs){
      if(jxs==0){
        swal("请选择经销商")
      }else{
        window.open("{:url('jxsyldc')}?cid="+cid+"&kid="+kid+"&jxs="+jxs)
      }
    }
    $(".emptyIf").click(function(){
      location.href="{:url('jxsyl')}"
    })
    $(".query").click(function(){
      if($("#jxs").val()==0){
        swal("请选择经销商")
      }else{
        document.getElementById("f1").submit();
      }
    })
    $("#fenqu").change(function(){
      var fid=$(this).val();
      $("#province").html('<option value="0">请选择</option>');
      $("#city").html('<option value="0">请选择</option>');
      $("#jxs").html('<option value="0">请选择</option>');
      $.post("{:url('fenqutosheng')}",{fid:fid},function(re){
          var data=JSON.parse(re);
          for(var i=0;i<data.length;i++){
            $("#province").append('<option value="'+data[i]["id"]+'">'+data[i]["title"]+'</option>')
          }
      })
    })
    $("#province").change(function(){
      var pid=$(this).val();
      $("#city").html('<option value="0">请选择</option>');
      $("#jxs").html('<option value="0">请选择</option>');
       $.post("{:url('shengtoshi')}",{pid:pid},function(re){
          var data=JSON.parse(re);
          for(var i=0;i<data.length;i++){
            $("#city").append('<option value="'+data[i]["id"]+'">'+data[i]["title"]+'</option>')
          }
      })
    })
    $("#city").change(function(){
      var cid=$(this).val();
      $("#jxs").html('<option value="0">请选择</option>');
       $.post("{:url('shitojxs')}",{cid:cid},function(re){
          var data=JSON.parse(re);
          for(var i=0;i<data.length;i++){
            $("#jxs").append('<option value="'+data[i]["id"]+'">'+data[i]["title"]+'</option>')
          }
      })
    })
        $(document).ready(function(){

           var $ObjectNum =$(".ObjectNum");
             toNum($ObjectNum);
             changeColor($ObjectNum)
             // console.log( $(".contTable tr:odd"))
            var trSuc=$("#Tinfo tr")
            trSuc.each(function(){
             $(this).find('td').eq(-1).css('background-color','#ffba8c');
            })
        })
       function changeColor(numObj)
         {
             for ( var i = 0; i < numObj.length; i++)
             {
                 var obj = numObj[i];
                 var num = parseFloat (obj.firstChild.nodeValue);
                
                 if(obj.text()=='-'){
                   obj.style.color = "#333333"
                 } else if(num>0){
                   obj.style.color = "#333333"
                 } else{
                   obj.style.color = "#f66"
                 }
             }
    };
   
   /*请输入关键字或空格查询*/
           var cainian = $("#cainian");
           var fenqu= $("#fenqu");
           var city= $("#city");
           var province= $("#province");
           var Agency= $("#Agency");
           var brand= $("#brand");
           var channel= $("#channel");
           var staff= $("#staff");
           sousuo(cainian);
           sousuo(fenqu);
           sousuo(city);
           sousuo(province);
           sousuo(Agency);
           sousuo(brand);
           sousuo(channel);
           sousuo(staff);

          function sousuo(id){
            id.bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: true, //以分隔符号分割的多关键字支持
            separator: ",", //多关键字支持时的分隔符，默认为空格
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: 'http://unionsug.baidu.com/su?p=3&t=' + (new Date()).getTime() + '&wd=',
            /*优先从url ajax 请求 json 帮助数据，注意最后一个参数为关键字请求参数*/
            jsonp: 'cb',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                var i, len, data = {
                    value: []
                };
                if (!json || !json.s || json.s.length === 0) {
                    return false;
                }

                // console.log(json);
                len = json.s.length;

                jsonStr = "{'value':[";
                for (i = 0; i < len; i++) {
                    data.value.push({
                        word: json.s[i]
                    });
                }
                data.defaults = 'baidu';

                //字符串转化为 js 对象
                return data;
            }
        });

          }
</script>
    </script>
</body>

</html>
